#pragma once
#include "cgzCTcpC.h"

class cgzCTcpWC;

class cgzCSendWC : public cgzCSendC
{
public:
    friend class cgzCTcpWC;
    cgzCSendWC(
        const char *data, 
        const int len, 
        int t, 
        bool mask = true, 
        const char *reason = nullptr);

    // 发给服务
    cgzCSendWC(cgzHeader &header, const int ufd);
    virtual ~cgzCSendWC();
};

class cgzCRecvWC : public cgzCRecvC
{
public:
    friend class cgzCTcpWC;
    cgzCRecvWC(int orgid, int tarid, const char *data, const int len, int t);
    virtual ~cgzCRecvWC();

public:
    int rt;
};

class cgzCTcpWC : public cgzCTcpC
{
public:
    cgzCTcpWC(
        cgzCThreadPool *pool, 
        const char *name, 
        const std::string ip, 
        const int port, 
        const int cid);
    virtual ~cgzCTcpWC();

protected:
    bool tcpsend() override;
    virtual bool decodeProc(cgzCWDecode &de);
public:
    bool connect(bool is_hand = false) override;
    bool handshake() override;
    bool sticking() override;
private:
    void sendhandshake();

private:
    std::string m_key;
    cgzCWDecode *m_pDecodeWC;
};
